import cv2
import numpy as np

# 0-255 : 0代表没有颜色  255 代表颜色的最大值
img = cv2.imread("./img/test.png")
print(img.dtype) # uint8 代表图像是无符号数的8位图像
# 已知img的形状是(257, 266, 3) => 3 ：三个通道
# B：blue G：green R：red
blue_channel = np.zeros(img.shape[:2])
green_channel = img[:, :, 1]
red_channel = np.zeros(img.shape[:2])

blue_channel = blue_channel.reshape(257, 266, 1)
green_channel = green_channel.reshape(257, 266, 1)
red_channel = red_channel.reshape(257, 266, 1)

blue_img = np.concatenate(
    [blue_channel,green_channel,red_channel],
    axis=2
)
print(blue_img.dtype) # float64 说明并没有使用正常的图像格式显示
# 修改blue_img的显示格式
blue_img = blue_img.astype(np.uint8)

cv2.imshow("blue_img", blue_img)
cv2.waitKey(0)
